//////////////////////////////////////////////////////////////
// TITLE: 			Append HD Panels
// DESCRIPTION:
// Append all panel files into one large panel. 
// Drop MPIDs flagged with timeseries issues.
//////////////////////////////////////////////////////////////

clear
foreach part of numlist 1/$groups {
	cap append using "$reconstruct/HD_part_`part'_panel_Q.dta"
}

// Id was unique within each file, but is not unique when appended. Redo id and tsset.
drop id
egen long id=group(MasterPortfolioId security_ident)
format date_q %tq
tsset id date_q

save "$output/hd_panels/HD_all_panels_global_Q", replace emptyok
compress
save "$output/hd_panels/HD_all_panels_global_Q", replace emptyok
